

var $$ = jQuery.noConflict();
(function($, doc) {
    $.init();
    $.ready(function() {
        //修改密码
        $$('#changePas').on('touchend',function(){
            openPage('/wechat/retrievePwd')
        })
        //form表单
        $$('#enter').on('touchend', function() {
            var i = 0;
            mui("#formData input").each(function() {
                if(!this.value || this.value.trim() == "") {
                    var label = this.previousElementSibling;
                    mui.alert(label.innerText + "不允许为空");
                    return false;
                } else {
                    i = i + 1
                }
            });
            if (i == 2) {
            	if(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test($$('#enterphone').val())){
                    mui(this).button('loading');
                    $$('#enter').prop('disabled','true')
                    $.post('/login',{'phone':$$('#enterphone').val(),'password':$$('#enterword').val(),'type':'wechat'},function (data) {
                        mui('#enter').button('reset');
                        $$('#enter').prop('disabled','false')
                        if(data.code==10013){
                            openPage('/wechat/toMain')
                        }else if(data.code==20007){
                            mui.alert('用户名不存在!');
                        }else if(data.code==10012){
                            mui.alert('请先绑定微信');
                            window.location.href='/wechat/toBind'
                        }else if(data.code==20008){
                            mui.alert('用户名或密码错误!');
                        }
                    })
				}else{
                    mui.alert('请输入正确手机号!');
				}
            }
        })
    });
})(mui, document);
